import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { Demo2VO, Demo2Form, Demo2Query,Demo2LineVO, Demo2LineQuery } from '@/api/demo/demo2/types';

/**
 * 查询测试主列表
 * @param query
 * @returns {*}
 */

export const listDemo2 = (query?: Demo2Query): AxiosPromise<Demo2VO[]> => {
  return request({
    url: '/demo/demo2/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询测试主详细
 * @param id
 */
export const getDemo2 = (id: string | number): AxiosPromise<Demo2VO> => {
  return request({
    url: '/demo/demo2/' + id,
    method: 'get'
  });
};

/**
 * 新增测试主
 * @param data
 */
export const addDemo2 = (data: Demo2Form) => {
  return request({
    url: '/demo/demo2',
    method: 'post',
    data: data
  });
};

/**
 * 修改测试主
 * @param data
 */
export const updateDemo2 = (data: Demo2Form) => {
  return request({
    url: '/demo/demo2',
    method: 'put',
    data: data
  });
};

/**
 * 删除测试主
 * @param id
 */
export const delDemo2 = (id: string | number | Array<string | number>) => {
  return request({
    url: '/demo/demo2/' + id,
    method: 'delete'
  });
};

/**
 * 查询测试子列表
 * @param query
 * @returns {*}
 */

export const listDemo2Line = (query?: Demo2LineQuery): AxiosPromise<Demo2LineVO[]> => {
  return request({
    url: '/demo/demo2/lineList',
    method: 'get',
    params: query
  });
};

/**
 * 删除测试子
 * @param lineId
 */
export const delDemo2Line = (lineId: string | number | Array<string | number>) => {
  return request({
    url: '/demo/demo2/lineId/' + lineId,
    method: 'delete'
  });
};
